
var layer = layui.layer
var form = layui.form;
let url = location.href;
let id = url.split("=")[1];
$.ajax({
    type: 'GET',
    url: '/admin/users/' + id,
    success: function (res) {
        if (res.status == 0) {
            form.val('example', res.data)
        } else {
            layer.msg(res.message)
        }
    }
})





function getedit() {
    $(".layui-form").submit(function (e) {
        let url = location.href;
        let id = url.split("=")[1];
        e.preventDefault()
        var data = $(this).serialize()
        data = "id=" + id + "&" + data
        $.ajax({
            type: "PUT",
            url: "/admin/users",
            data,
            success: function (res) {
                layer.msg(res.message)
            }
        })
    })
}
getedit()


$(".chongzhi").click(function () {
    document.querySelector(".layui-form").reset()
})

